package com.citywithincity.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyReader extends ConfigReader {
	protected Properties p = new Properties();
	
	public void load(String name) throws IOException {
		InputStream in = null;
		try {
			in = PathUtil.getConfigInputStream(PropertyReader.class,name);
			p.load(in);
		} finally {
			IoUtil.close(in);
		}
	}
	
	public void load(InputStream in) throws IOException{
		p.load(in);
	}
	

	public String get(String key)
	{
		String value = p.getProperty(key);
		if(value==null)return null;
		return value.trim();
	}
	
	
	public String get(String key, String defaultValue){
		 return p.getProperty(key, defaultValue);  
	}

	public int getInt(String key){
		String value = get(key);
		if(value==null)return 0;
		return Integer.parseInt(value);
	}
}
